package com.jt.controller;

import com.jt.anno.CacheFind;
import com.jt.mapper.ItemMapper;
import com.jt.pojo.ItemCat;
import com.jt.service.ItemCatService;
import com.jt.service.ItemService;
import com.jt.vo.EasyUITree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/item/cat/")
public class ItemCatController {

    @Autowired
    private ItemCatService itemCatService;

    @RequestMapping("queryItemName")
    @CacheFind(key = "ITEM_CAT_NAME")
    public String getObjectById(Long itemCatId){
        return itemCatService.getObjectById(itemCatId);
    }

    /**
     * 业务需求:实现商品分类的展现
     * url:item/cat/list
     * 参数:parentId=0
     * 返回结果:List<EasyUITree>
     */
    @RequestMapping("list")
    public List<EasyUITree> findItemCatList(Long id){
        Long parentId=(id==null)?0:id;
        return itemCatService.findItemCatList(parentId);
       // return itemCatService.findItemCache(parentId);
    }
}
